// 封装和牛马相关的功能
import request from '@/utils/request'
/**
 * 获取员工列表
 * @param {Object} params page pagesize departmentId keyword(可选)
 * @returns 请求
 */
export const getEmployeeList = (params) =>
  request({
    url: '/sys/user',
    method: 'get',
    params: params
    // {
    //   page: 1,
    //   pagesize: 20,
    //   departmentId: 1,
    //   keyword: ''
    // }
  })
// 添加员工信息
export const addEmployeeSimple = () =>
  request({
    url: `/sys/user`
  })
// 导出员工信息
export const exportEmployee = () =>
  request({
    url: '/sys/user/export',
    method: 'get',
    responseType: 'blob'
  })
/**
 * 获取模板文件
 * @returns 请求
 */
export const getTemplateData = () => {
  return request({
    url: '/sys/user/import/template',
    responseType: 'blob'
  })
}
// 上传文件
export function upLoadFile(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/sys/user/import',
    method: 'post',
    data: formData
  })
}
// 添加员工
export function addEmployee(data) {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}
// 数据回显/**

export function getEmployeeDetail(id) {
  return request({
    url: `/sys/user/${id}`
  })
}

// 修改
export function updateEmployee(data) {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}
